<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>编辑</title>
</head>
<style>
    *{font-size: 12px; margin-top:0.2em}
    .tableDiv{width: 60vw; margin: 0 auto;}
    table tr td {border-bottom: 1px solid #cccccc;}
    table tr td input,textarea{display:block; min-width: 50vw;}
    table tr td textarea{height: 10em}
</style>

<body>
<form th:method="POST" th:action="@{/admin/menu/saveMenu}">
    <div th:if="${not #strings.isEmpty(menu.menuId)}">
        <input type="hidden" name="menuId" th:value="${menu.menuId}"/>
    </div>
    <div th:object="${menu}" class="tableDiv">
        <table>
            <tr>
                <td><laber>父级菜单ID</laber></td>
                <td><input th:type="text" name="parentMenuId" th:value="*{parentMenuId}"/></td>
            </tr>
            <tr>
                <td><laber>菜单编码</laber><span style="color:red">*</span></td>
                <td><input th:type="text" name="menuCode" th:value="*{menuCode}"/></td>
            </tr>
            <tr>
                <td><laber>类型</laber><span style="color:red">*</span></td>
                <td>
                    <select name="menuType"/>
                        <option id="tmenu" value="1" th:selected="*{menuType eq 1}">菜单</option>
                        <option id="tbutton" value="2" th:selected="*{menuType eq 2}">按钮</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><laber>菜单名称</laber><span style="color:red">*</span></td>
                <td><input th:type="text" name="menuName" th:value="*{menuName}"/></td>
            </tr>
            <tr>
                <td><laber>菜单别名</laber></td>
                <td><input th:type="text" name="menuAlias" th:value="*{menuAlias}"/></td>
            </tr>
            <tr>
                <td><laber>URI</laber></td>
                <td><input th:type="text" name="menuUri" th:value="*{menuUri}"/></td>
            </tr>
            <tr>
                <td><laber>ICON</laber></td>
                <td><input th:type="text" name="menuIcon" th:value="*{menuIcon}"/></td>
            </tr>
            <tr>
                <td><laber>菜单描述</laber></td>
                <td><textarea th:type="text" name="remark" th:text="*{remark}"/></td>
            </tr>
            <tr>
                <td><laber>有效状态</laber><span style="color:red">*</span></td>
                <td>
                    <select name="state"/>
                    <option id="succ" value="1">有效</option>
                    <option id="fail" value="0">无效</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><laber>排序</laber></td>
                <td><input th:type="text" name="sort" th:value="*{sort}"/></td>
            </tr>
        </table>
        <button th:type="submit">保存</button>
    </div>
</form>
</body>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    document.addEventListener('DOMContentLoaded',
        function(){
            var succ = document.getElementById("succ");
            var fail = document.getElementById("fail");
            var i = [[${menu.state}]];
            if (i == 0) {
                fail.selected = true;
            } else {
                succ.selected = true;
            }
        },
        false);
    /*]]>*/
</script>
</html>
